import json, base64, random
from quanquaner.models.BaseModels import Log
#from Crypto.Cipher import AES

def saveLog(data):
    dict = {
        'openid': data['openid'],
        'log': data['log'],
    }
    if Log.objects.create(**dict):
        return True
    else:
        return False

def getRandom(num):
    data = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
    result = ''
    for i in range(num):
        a = random.choice(data)
        result += a
    return result
